# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Denis Martinez <deuns.martinez@gmail.com>

pkgname=wt
pkgver=4.10.1
pkgrel=1
pkgdesc="a C++ library and application server for developing and deploying web applications"
arch=('loong64' 'x86_64')
url="http://www.webtoolkit.eu/"
license=('GPL')
depends=('boost-libs' 'libharu' 'graphicsmagick' 'pango' 'zlib' 'libgl' 'harfbuzz'
         'qt5-base')
makedepends=('boost' 'cmake' 'postgresql-libs' 'fcgi' 'sqlite' 'mysql++' 'doxygen'
             'graphviz' 'mesa' 'glu' 'ninja')
optdepends=('openssl: for SSL support in built-in webserver'
	    'fcgi: for FastCGI support'
	    'postgresql-libs: for PostgreSQL Dbo support'
        'mariadb-libs: for MySQL Dbo support'
	    'sqlite: for Sqlite Dbo support'
	    'mysql++: for the hangman example')
backup=('etc/wt/wt_config.xml')
source=("$pkgname-$pkgver.tar.gz::https://github.com/kdeforche/wt/archive/${pkgver}.tar.gz"
        $pkgname-207.patch::https://patch-diff.githubusercontent.com/raw/emweb/wt/pull/207.patch)
sha512sums=('cb90ce633b88adf49037ec8cbf8d38f83a746b7b2c21345a406b66fc035677f0d57ad80f25999ac8c42186b6ce7ed9d9d2d3cf8ee132a826007c200f4009363c'
            '808d0037d0d3c039488b00effb753dacbaa949430a99617c83fff94fe50a76a0984f0b56d1ba66f4cc5b3520357e04827470e8cf55f3d854a0fe8453fcc7ad06')

prepare() {
  cd ${pkgname}-${pkgver}

  patch -Np1 -i "${srcdir}"/$pkgname-207.patch
}

build() {
  cd ${pkgname}-${pkgver}

  cmake \
      -Bbuild \
      -GNinja \
      -DCONNECTOR_HTTP=ON \
      -DWT_WRASTERIMAGE_IMPLEMENTATION=GraphicsMagick \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DWEBUSER=http \
      -DWEBGROUP=http \
      -DUSE_SYSTEM_SQLITE3=ON \
      -DINSTALL_EXAMPLES=ON \
      -DBUILD_EXAMPLES=ON
  ninja -C build
}

package() {
  cd "$srcdir"/${pkgname}-${pkgver}

  DESTDIR="$pkgdir" ninja -C build install
}
